<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="../../../common/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<sfa:mainTitle></sfa:mainTitle>
		<%@ include file="../../../common/meta.jsp"%>
		<script type="text/javascript">
$(function() {
	$("#btn_add").click(
			function() {

			var productList = $(".saleProduct:checked");
			var triantype = $("#trainType").val();
				//alert(triantype);
				if (productList.length == 0) {
					alert("请选择要添加的人员!");
					return false;
				}
				var productStr = "";
				productList.each(function(i, o) {
					trainerName = $(o).val();
					brachid =$(o).next().val();		
				});
				//alert(brachid);
				parent.addProducts(trainerName,brachid,triantype);
				
			});
			
	
		$("#trainType").change(function(){
			$("#triantype").hide();
		});
});
 
</script>
	</head>
	<body>

		<div class="webpart3 contentarea">
			<div class="webpart-head">
				<div class="webpart-head-item">
					外勤关联
				</div>
			</div>
			<div class="webpart-main" id="maindiv">
				<div class="webpart-main-item" style="padding-top: 12px;">
					<div class="search">
						<form method="get" id="from">
							<table  cellpadding="0" cellspacing="0"
								style="margin-top: 0px; text-align: center;">
								<tbody>
									<tr>
										<th>
											代码
										</th>
										<td>
											<input type="text" name="agentcode" id="agentcode"
												class="inputbox" value="${agentcode}">
										</td>
										<th>
											名字
										</th>
										<td>
											<input type="text" name="trainerName" id="trainerName"
												class="inputbox" value="${trainerName}">
										</td>
										<td>
											<span> 机构</span>
										</td>
										<td>
											<select class="selectbox" name="branchid" id="branchid">
												<option value="ALL">
													全部
												</option>
												<c:forEach items="${BranchList}" var="branch">
													<option value="${branch.branchId }"
														<c:if test="${branchid==branch.branchId }">selected='selected'</c:if>>
														${branch.branchName}
													</option>
												</c:forEach>
											</select>
										</td>
									</tr>
									<tr>
										<td>
											兼讲类型
										</td>
									<td>
									
									<select class="selectbox" name="trainType" id="trainType">
									<c:forEach items="${traintypeList}" var="list">
													<option value="${list.salerecordid}"
														<c:if test="${traintype==list.salerecordid }">selected='selected'</c:if>>
														${list.chnname}
													</option>
												</c:forEach>
									</select>			
									 
									</tr>
									<tr>
										<td colspan="6" class="table_btn">
											<input type="submit" class="linkbtn2" value="查询" />
											&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
											<input type="button" class="linkbtn2" value="清空"
												onclick="location.href='${path}/productandtrain/lecturer/index/operation';" />
										</td>
									</tr>
								</tbody>
							</table>
						</form>
						 <div id="triantype"">
						<table id="mytable" cellpadding="0" cellspacing="0"
							class="dg_borderstyle  trStyleTable"
							style="margin-top: 0px; text-align: center; width: 100%">
							<tbody>
								<tr class="tabheader">
									<th>
										内勤关联
									</th>
									<th>
										代理人代码
									</th>
									<th>
										代理人名字
									</th>
									<th>
										机构
									</th>
									 
								</tr>	
								<c:forEach items="${internal.resultList}" var="product">
									<tr id="tr_${product.PRODUCTID}" class="gray datarow">
										<td>
											<input type="radio" class="saleProduct" name="saleProduct" value="${product.USERNAME}" />
											<input type="hidden" value="${product.breachid}" />
										 
										</td>
										<td>
											${product.loginname}
										</td>
										<td>
											${product.USERNAME}
										</td>
										<td>
											<span>${product.branchname}</span>
										</td>
										 

									</tr>
								</c:forEach>
							
							</tbody>
						</table>
					
						<c:if test="${not empty internal.multiPage}">
							<div class="dg_pagerstyle">
								<div class="pagebtn">
									${internal.multiPage}
								</div>
							</div>
						</c:if>
 
						
						<input type="button" class="com_btn" id="btn_add"
							style="margin-left: 85%; margin-top: 8px;" value="添加到新建讲师" />
							 </div>
					</div>
				</div>
			</div>
			<div class="webpart-foot">
				<div class="webpart-foot-item">
				</div>
			</div>
		</div>
	</body>
</html>